program define oi_graph_export
	syntax anything(name=path id="File path without extension"), [type(string) MANUALedit]

	if !inlist("`type'", "paper", "slides", "both") {
		di as error "Specified type must be either 'paper' or 'slides' or 'both'"
		exit 198
	}

	if ("`c(os)'" == "Windows") {
		if ("`manualedit'" != "") | ("`type'" == "slides") local img wmf
		else local img pdf
	}
	else {
		if ("`manualedit'" != "") | ("`type'" == "slides") local img svg
		else local img pdf
	}
	local path = substr(`path', 1, .)

	* Export both file types if desired; else just export the specified file type
	if "`type'" == "both" {
		if ("`c(os)'" == "Windows") {
			graph export "`path'.wmf", replace
			project, creates("`path'.wmf") 
		}
		else {
			graph export "`path'.svg", replace
			project, creates("`path'.svg") 
		}
		graph export "`path'.pdf", replace
		project, creates("`path'.pdf")
	}
	else {
		graph export "`path'.`img'", replace
		project, creates("`path'.`img'")
	}
end
